#ifndef __IST8310_H
#define __IST8310_H
#ifdef __cplusplus
extern "C"{
#endif

#include "rtdef.h"



typedef struct ist8310_raw_data_t {
    float x;
    float y;
    float z;
} ist8310_raw_data_t;

typedef enum ist8310_error_e {
    IST8310_NO_ERROR = 0x00,
    MEG_ID_ERROR = 0x01,
    ist8310_no_init =0x02,
} ist8310_error_e;

typedef struct ist8310_data_t {
    uint8_t chip_id;
    uint8_t status;
    ist8310_error_e ist8310_error;
    ist8310_raw_data_t raw_data;
} ist8310_data_t;

extern ist8310_data_t ist8310_data;
extern rt_sem_t ist8310_sem;


// 基础读取函数
uint8_t ReadSingleDataFromIST8310(uint8_t addr);
void WriteSingleDataFromIST8310(uint8_t addr, uint8_t data);
void ReadMultiDataFromIST8310(uint8_t addr, uint8_t* data, uint8_t len);
void WriteMultiDataFromIST8310(uint8_t addr, uint8_t* data, uint8_t len);

// 功能函数
void ReadIST8310Data(ist8310_data_t* meg_data);

// 校验函数
ist8310_error_e VerifyMegId(uint8_t* id);


#ifdef __cplusplus
}
#endif

#endif // IST8310_H